﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace G.APITest.ChildWindows
{
    public partial class GetOnlineProjectChildWindow : ChildWindow
    {
        public GetOnlineProjectChildWindow()
        {
            InitializeComponent();
        }
        protected override void OnOpened()
        {
            base.OnOpened();
            GloabalData.Instance.SampleClient.Execute(new Service.API.Request.APITest.GetAPITestProjectListRequest() { UserId = GloabalData.Instance.UserInfo.ID }, (c) =>
            {
                if (c.IsOK)
                {
                    list.ItemsSource = c.ResponseData;
                }
                else
                {
                    MessageBox.Show(c.Msg);
                }
                progress.Visibility = System.Windows.Visibility.Collapsed;
            });
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
        public Service.API.Domain.APITest.APIProjectConfigInfo APIProjectConfigInfo { get; private set; }
        private void list_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            if (list.SelectedItem != null)
            {
                APIProjectConfigInfo = list.SelectedItem as G.Service.API.Domain.APITest.APIProjectConfigInfo;
                this.DialogResult = true;
            }
        }
    }
}

